package com.jiangjun.fetch.threadpool;

import EDU.oswego.cs.dl.util.concurrent.Callable;

import com.jiangjun.fetch.FetchRss;
import com.jiangjun.fetch.common.AttributeChain;
import com.jiangjun.fetch.common.WebContext;
import com.jiangjun.fetch.filter.FilterChain;
import com.jiangjun.fetch.servlet.Start;

public class FetchHandleCallable implements Callable {
	
	private FilterChain fls = (FilterChain) Start.factory.getBean("filterChain");
	
	private FetchRss fetchRss;
	
	public FetchHandleCallable(FetchRss fetchRss)
	{
		this.fetchRss = fetchRss;
	}

	@Override
	public Object call() throws Exception {
		// TODO Auto-generated method stub
		WebContext ctx = new WebContext();
		ctx.setFetch(fetchRss);
		ctx.setId(fetchRss.getId());
		if(fetchRss.getParent_id() != null && !"".equals(fetchRss.getParent_id()))
		{
			ctx.setParentId(fetchRss.getParent_id());
		}
		ctx.setDes(fetchRss.getDes());
		if(fetchRss.getParent_name() != null && !"".equals(fetchRss.getParent_name()))
		{
			ctx.setParentName(fetchRss.getParent_id());
		}
		ctx.setUrl(fetchRss.getUrl());
		ctx.setXpath(fetchRss.getXpath());
		ctx.setType(fetchRss.getType());
		ctx.setLastUpdateTime(fetchRss.getDate());
		ctx.setIsRssXml(fetchRss.getIsRssXml());
		fls.doProcess(ctx, AttributeChain.HTTPCLIENT_FILTER);
		return null;
	}

}
